package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormNewMemoryStandardDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormNewMemoryStandardDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormNewMemoryStandardDetailConverter {

    public static FlowFormNewMemoryStandardDetailDto do2Dto(FlowFormNewMemoryStandardDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        return FlowFormNewMemoryStandardDetailMapper.INSTANCE.do2Dto(domain);
    }

    public static List<FlowFormNewMemoryStandardDetailDto> do2Dto(List<FlowFormNewMemoryStandardDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormNewMemoryStandardDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormNewMemoryStandardDetail dto2Do(FlowFormNewMemoryStandardDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        return FlowFormNewMemoryStandardDetailMapper.INSTANCE.dto2Do(dto);
    }

    public static List<FlowFormNewMemoryStandardDetail> dto2Do(List<FlowFormNewMemoryStandardDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormNewMemoryStandardDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormNewMemoryStandardDetailMapper {

        FlowFormNewMemoryStandardDetailMapper INSTANCE = Mappers.getMapper(FlowFormNewMemoryStandardDetailMapper.class);

        FlowFormNewMemoryStandardDetailDto do2Dto(FlowFormNewMemoryStandardDetail domain);

        List<FlowFormNewMemoryStandardDetailDto> do2Dto(List<FlowFormNewMemoryStandardDetail> domain);

        FlowFormNewMemoryStandardDetail dto2Do(FlowFormNewMemoryStandardDetailDto dto);

        List<FlowFormNewMemoryStandardDetail> dto2Do(List<FlowFormNewMemoryStandardDetailDto> dto);
    }
}
